package com.zf.shuashua.ui.popup;

import android.app.Activity;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.zf.shuashua.R;

/**
 * 登录弹框
 */
public class LoginPopup extends CenterPopupView {

    private TextView btnTitle;
    private ImageView imgClose;
    private OnPopupListener mListener;

    public LoginPopup(@NonNull Activity context) {
        super(context);
    }

    public void setPopupListener(OnPopupListener listener) {
        this.mListener = listener;
    }

    public void close() {
        dismiss();
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.red_popup;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        setupView();
    }

    private void setupView(){
        btnTitle = findViewById(R.id.btTitle);
        imgClose = findViewById(R.id.img_close);
        btnTitle.setOnClickListener(v -> {
            if(mListener != null){
                mListener.onNext();
            }
        });
        imgClose.setOnClickListener(v -> {
            dismiss();
            if(mListener != null){
                mListener.onClose();
            }
        });
    }

}

